package com.moensun.akka.springboot.akka;

import akka.actor.UntypedActor;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.inject.Named;

/**
 * Created by Bane.Shi.
 * Copyright MoenSun
 * User: Bane.Shi
 * Date: 2017/3/8
 * Time: 15:58
 */
@Component("CountingActor")
@Scope("prototype")
public class CountingActor extends UntypedActor {

	public CountingActor() {
	}

	public static class Count {};

	public static class Get {};

	public void onReceive(Object o) throws Throwable {
		if(o instanceof Count){
			System.out.println(o);
		}else if(o instanceof Get){
			getSender().tell("1",getSelf());
		}else {
			unhandled(o);
		}
	}
}
